package com.xhu.collegestudentrentalsystem.module.user.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhu.collegestudentrentalsystem.module.user.entity.HouseOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author zhu huilin
 * @date 2023/3/11 14:45
 */
public interface HouseOrderDAO extends BaseMapper<HouseOrder> {

    /**
     * 修改订单状态
     */
    @Update("update house_order set `status` = #{status} where id = #{orderId}")
    public Integer updateOrderStatus(@Param("orderId")Long orderId, @Param("status")Integer status);

    /**
     * 查询某房子的租住人数
     */
    @Select("SELECT COUNT(DISTINCT customer_user_id) FROM house_order WHERE `status` IN(-1,0) AND house_id = #{houseId}")
    public Integer findHouseOrderUserNum(@Param("houseId") Long houseId);

}
